package com.sskj.community.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.community.ui.fragment.HotFragment;
import com.sskj.lib.bean.BorrowMoneyRecordBean;
import com.sskj.lib.bean.HotBean;
import com.sskj.lib.http.JsonCallBack;


/**
 * @author Hey
 * Create at  2019/06/25
 */
public class HotPresenter extends BasePresenter<HotFragment> {
    public void getHotList(int p, String size) {
        httpService.getHotList(p, size)
                .tag(this)
                .execute(new JsonCallBack<HttpData<HotBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<HotBean>> response) {
                        HttpData<HotBean> body = response.body();
                        HotBean data = body.getData();
                        mView.getHotListSuccess(data);
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }
    public void getHotListLogin(int p, String size) {
        httpService.getHotListLogin(p, size)
                .tag(this)
                .execute(new JsonCallBack<HttpData<HotBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<HotBean>> response) {
                        HttpData<HotBean> body = response.body();
                        HotBean data = body.getData();
                        mView.getHotListSuccess(data);
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }


    public void goLike(String islike, String msg_id,boolean flag) {
        httpService.setLike(islike, msg_id)
                .tag(this)
                .execute(new JsonCallBack<HttpData>(flag?this:null) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        mView.setLikeSuccess();
                    }
                });
    }
}
